
var url  = location.search;
var resdata;
var theRequest = new Object();  
if ( url.indexOf( "?" ) != -1 ){  
var str = url.substr( 1 ); //substr()方法返回从参数值开始到结束的字符串；  
var strs = str.split( "&" ); 
var time = new Date();
var day = ("0" + time.getDate()).slice(-2);
var month = ("0" + (time.getMonth() + 1)).slice(-2);
var today = time.getFullYear() + "-" + (month) + "-" + (day) ;
for ( var i = 0; i < strs.length; i++ ) {  
theRequest[ strs[ i ].split( "=" )[ 0 ] ] = ( strs[ i ].split( "=" )[ 1 ] );  
}  
}
$(document).ready(function(){
	$('#name').text(sessionStorage.getItem("name"));
	getData(theRequest.processId,theRequest.sno);
});
function getData(processId,sno){
	var ss={};
	ss.prno = processId;
	ss.sno = sno;
	ss.type='timeline';
	var tubiao = "&#xe63f;"
	var color = "";
		$.ajax({
  	    	url: "../../process_info_detail/getSelectBody"
  	        ,type:'post'
  	        ,dataType:'json'
  	        ,contentType: "application/json; charset=utf-8"
  	        ,data:JSON.stringify(ss)  
  	        ,success: function(res){
  	          	console.log(res.data);
				for(var i=0;i<res.data.length;i++){
					if(res.data[i].planstartdate >= today && res.data[i+1].planstartdate <today){tubiao = "&#xe617;"}else{tubiao = "&#xe63f;"}
					if(res.data[i].flag == '0'){color="red"}else{color=""}
					if(i==0||(i>0&&(res.data[i].planstartdate!=res.data[i-1].planstartdate))){
					$("#timeline").append('<li class="layui-timeline-item">'
			   		   +'<i class="layui-icon layui-timeline-axis">'+tubiao+'</i>'  //&#xe617;
			           +'<div class="layui-timeline-content layui-text" id="text'+i+'">'
					   +'<h3 class="layui-timeline-title">'+res.data[i].planstartdate+'</h3>'
					   +'<p onclick="timelinedetail(\''+res.data[i].sno+'\',\''+res.data[i].prno+'\',\''+res.data[i].prdno+'\')" style="margin-right:30px;color:'+color+'">'
				       +res.data[i].project   +' &nbsp;&nbsp  ------------' +res.data[i].dutyuser
				       +'</p>'
					);
					for(var s=i+1;s<res.data.length;s++){
						if(res.data[s].planstartdate==res.data[i].planstartdate){
							if(res.data[s].flag == '0'){color="red"}else{color=""}
							$("#text"+i).append('<p onclick="timelinedetail(\''+res.data[i].sno+'\',\''+res.data[i].prno+'\',\''+res.data[i].prdno+'\')" style="margin-right:30px;color:'+color+'">'
						       +res.data[s].project  +' &nbsp;&nbsp  ------------' +res.data[s].dutyuser
						       +'</p>'
							);
						}
					}
					$("#timeline").append('</div>'
  				       +'</li>'
					);
					}
				}
				
  	        }
		,error:function(XMLHttpRequest, textStatus, errorThrown) {
			alert(XMLHttpRequest);
			 alert(textStatus);
			 alert(errorThrown);
			 hideloading();
		}
  	    });

	/*var sendData = {};
	sendData.userid = sessionStorage.getItem("userId");
	sendData.starttime = $('#startDate').val();
	sendData.endtime = $('#endDate').val()
	sendData.shopcode=$('#shopcode').val();
   	sendData.shenheflag=$('#flagSelect').val();
	$.ajax({
		url: "../../shop_open_info/getResult"
		,type:'post'
//		,async: false
		,data:JSON.stringify(sendData)
		,contentType: "application/json; charset=utf-8"
		,dataType:'json'
		,success: function(res){
			console.log(res.data);
			resdata =res.data;
			setTableList();
		}
		,error:function(XMLHttpRequest, textStatus, errorThrown) {
			 console.log(XMLHttpRequest);
			 console.log(textStatus);
			 console.log(errorThrown);
			 hideloading();
		}
	});*/
}
function timelinedetail(sno,processId,processdId){
	url = "shop_open_timeline_detail?processId="+processId+"&sno="+sno+"&processdId="+processdId;//此处拼接内容
	window.location.href = url;
}
